package org.fyv233.missingno_craft.datagen;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.RecipeProvider;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.util.Identifier;
import org.fyv233.missingno_craft.Missingno_craft;
import org.fyv233.missingno_craft.block.ModBlocks;
import org.fyv233.missingno_craft.item.ModItems;

import java.util.concurrent.CompletableFuture;

public class ModRecipeProvider extends FabricRecipeProvider {
    public ModRecipeProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
        super(output, registriesFuture);
    }

    @Override
    public void generate(RecipeExporter recipeExporter) {
        offerReversibleCompactingRecipes(recipeExporter, RecipeCategory.MISC, ModItems.MISSINGNO_INGOT,
                RecipeCategory.MISC, ModItems.MISSINGNO_NUGGET);

        offerReversibleCompactingRecipes(recipeExporter, RecipeCategory.BUILDING_BLOCKS, ModBlocks.MISSINGNO_BLOCK,
            RecipeCategory.MISC, ModItems.MISSINGNO_INGOT, "1_m", "1_m", "2_m", "2_m");

        ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, ModItems.MISSINGNO_PROSPECTER, 1)
                .pattern("  #")
                .pattern(" A ")
                .pattern("A  ")
                .input('#', Ingredient.ofItems(ModItems.MISSINGNO_INGOT))
                .input('A', Ingredient.ofItems(Items.DIAMOND))
                .criterion("has_item", RecipeProvider.conditionsFromItem(ModItems.MISSINGNO_PROSPECTER))
                .offerTo(recipeExporter, Identifier.of(Missingno_craft.MOD_ID, "craft_missingno_prospecter"));

        ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, ModItems.MISSINGNO_PICKAXE, 1)
                .pattern("A#A")
                .pattern("ABA")
                .pattern("AAA")
                .input('A',  Ingredient.ofItems(Items.DIAMOND))
                .input('B', Ingredient.ofItems(Items.NETHERITE_PICKAXE))
                .input('#', Ingredient.ofItems(ModItems.MISSINGNO_INGOT))
                .criterion("has_item", RecipeProvider.conditionsFromItem(ModItems.MISSINGNO_PICKAXE))
                .offerTo(recipeExporter, Identifier.of(Missingno_craft.MOD_ID, "craft_missingno_pickaxe"));

        ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, ModItems.MISSINGNO_AXE, 1)
                .pattern("A#A")
                .pattern("ABA")
                .pattern("AAA")
                .input('A',  Ingredient.ofItems(Items.DIAMOND))
                .input('B', Ingredient.ofItems(Items.NETHERITE_AXE))
                .input('#', Ingredient.ofItems(ModItems.MISSINGNO_INGOT))
                .criterion("has_item", RecipeProvider.conditionsFromItem(ModItems.MISSINGNO_AXE))
                .offerTo(recipeExporter, Identifier.of(Missingno_craft.MOD_ID, "craft_missingno_axe"));

        ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, ModItems.MISSINGNO_HOE, 1)
                .pattern("A#A")
                .pattern("ABA")
                .pattern("AAA")
                .input('A',  Ingredient.ofItems(Items.DIAMOND))
                .input('B', Ingredient.ofItems(Items.NETHERITE_HOE))
                .input('#', Ingredient.ofItems(ModItems.MISSINGNO_INGOT))
                .criterion("has_item", RecipeProvider.conditionsFromItem(ModItems.MISSINGNO_HOE))
                .offerTo(recipeExporter, Identifier.of(Missingno_craft.MOD_ID, "craft_missingno_hoe"));

        ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, ModItems.MISSINGNO_SWORD, 1)
                .pattern("A#A")
                .pattern("ABA")
                .pattern("AAA")
                .input('A',  Ingredient.ofItems(Items.DIAMOND))
                .input('B', Ingredient.ofItems(Items.NETHERITE_SWORD))
                .input('#', Ingredient.ofItems(ModItems.MISSINGNO_INGOT))
                .criterion("has_item", RecipeProvider.conditionsFromItem(ModItems.MISSINGNO_SWORD))
                .offerTo(recipeExporter, Identifier.of(Missingno_craft.MOD_ID, "craft_missingno_sword"));

    }
}
